<template>
  <div class="list">
    <div v-for="item in date" class="item">
      <div class="itemLeft">{{item.match_begin_time|filte}}</div>
      <div class="itemTop" @click="itemShow(item)">
        <div class="left">
          <p class="sLogo"><img :src="item.home_crop.crop_logo"/></p>
          <p class="sName">{{item.home_crop.crop_name}} (主)</p>
        </div>
        <div class="info">
          <p class="sIcon"></p>
        </div>
        <div class="right">
          <p class="sLogo"><img :src="item.away_crop.crop_logo"/></p>
          <p class="sName">{{item.away_crop.crop_name}} (客)</p>
        </div>
      </div>
      <div v-if="item.match_status==1" class="itemBottom">
        <p v-if="item.sport_match_set.length>0" v-for="list in item.sport_match_set" @click="click(list)" class="pay">{{list.content|title}} ({{list.content|txtle}})<span>{{list.odds}}</span></p>
        <p v-if="item.sport_match_set.length<1">未开盘</p>
      </div>

      <div v-if="item.match_status==2" class="itemMessage">
        比赛进行中
      </div>

      <div v-if="item.match_status==3" class="itemMessage">
        比赛已结束
      </div>

    </div>


  </div>
</template>
<script>
import {mapActions} from 'vuex'
import '@/assets/style/common.less'
export default {
  name: 'list',
  props:['date'],
  data() {
    return {
        id:'',
        price:''
    }
  },
  filters:{
      filte(e){
          let time=e.substring(10,16)
          return time
      },
      title(e){
        let title
        let date=JSON.parse(e)
        if(date.total_score_max!=undefined){
          title="总分大于"
        }else if(date.total_score_min!=undefined){
          title="总分小于"
        }else if(date.home_let_point!=undefined){
          title="主队全场"
        }else if(date.home_half_let_point!=undefined){
          title="主队上半场"
        }else if(date.away_let_point!=undefined){
          title="客队全场"
        }else if(date.away_half_let_point!=undefined){
          title="客队上半场"
        }
        return title
      },
      txtle(e){
        let title
        let date=JSON.parse(e)
        if(date.total_score_max!=undefined){
          title=date.total_score_max
        }else if(date.total_score_min!=undefined){
          title=date.total_score_min
        }else if(date.home_let_point!=undefined){
          title=date.home_let_point
        }else if(date.home_half_let_point!=undefined){
          title=date.home_half_let_point
        }else if(date.away_let_point!=undefined){
          title=date.away_let_point
        }else if(date.away_half_let_point!=undefined){
          title=date.away_half_let_point
        }
        return title
      }
  },
  mounted(){
    this.setDate()
  },
  methods:{
    click(e){
      if(this.vLogin()){
        this.$store.dispatch('payId', e.id)
        this.$store.dispatch('payStart', true)
      }else{
        this.$router.push('/login')
      }
      
    },
    setDate(){
      let that=this
      this.date.forEach(function (value,i) {
          that.$set(value,'state',false);
      });
    },
    itemShow(e){
      e.state=!e.state
    }
  }
}

</script>
